package com.byzx.wine.service.impl;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.byzx.wine.dao.SyauthorityDao;
import com.byzx.wine.dao.SyauthorityMapper;
import com.byzx.wine.po.Syauthority;
import com.byzx.wine.service.ISyauthorityService;
@Service
public class SyauthorityService implements ISyauthorityService {
	
	@Autowired
	private SyauthorityDao syauthorityDao;
	@Autowired
	private SyauthorityMapper syauthority;
	@Override
	public List<Map<String, Object>> findSyauthority() {
		// TODO Auto-generated method stub
		return syauthority.findSyauthority();
	}
	@Override
	public int deleteByPrimaryKey(Integer id) {
		// TODO Auto-generated method stub
		return syauthority.deleteByPrimaryKey(id);
	}
	@Override
	public Syauthority selectByPrimaryKey(Integer id) {
		// TODO Auto-generated method stub
		return syauthority.selectByPrimaryKey(id);
	}
	@Override
	public int updateByPrimaryKey(Syauthority record) {
		// TODO Auto-generated method stub
		return syauthority.updateByPrimaryKey(record);
	}
	@Override
	public int insert(Syauthority record) {
		// TODO Auto-generated method stub
		return syauthority.insert(record);
	}

	
	@Override
	public List<Map<String, Object>> findUserSyauthority(String name) {
		

		List<Syauthority> list =syauthorityDao.findUserSyauthority(name);
		
		List<Map<String, Object>> list1 = new ArrayList<Map<String, Object>>();	
		
		for (int i = 0; i < list.size(); i++) {
			
			Map<String, Object> map = new HashMap<String, Object>();
			map.put("id", list.get(i).getId());
			map.put("pid", list.get(i).getPid());
			map.put("name", list.get(i).getName());
			map.put("src", list.get(i).getSrc());
			map.put("open", false);			
			list1.add(map);	
		}
	return list1;
	}
	
	
		
}
